****************************************************************************************************************************************************
***Preparing variables for: "Greed, Envy, and Admiration: The Distinct Nature of Public Opinion about Redistribution from the Rich" ****************
****************************************************************************************************************************************************
****************************************************************************************************************************************************
****************************************************************************************************************************************************

*set working directory 
*to produce tables, download and install esttab: ssc install estout 
*to produce figures, download and install coefplot: ssc install coefplot

********************
******Sample 1******
********************

use "Data1", clear 

*Effort of the poor
recode poor_ef (99=.)
generate effort_poor = (poor_ef-1)/6
label variable effort_poor "Effort poor"

*Effort of the rich
recode rich_ef (99=.)
generate effort_rich = (rich_ef-1)/6
label variable effort_rich "Effort rich"

*Prosociality of the poor
recode poor_like (99=.)
generate proso_poor = (poor_like-1)/6
label variable proso_poor "Prosocial poor"

*Prosociality of the rich
recode rich_like (99=.)
generate proso_rich = (rich_like-1)/6
label variable proso_rich "Prosocial rich"

*Gender
recode gender (1=0 "Female") (2=1 "Male"), generate(Gender) 
label variable Gender "Gender (Male)"

*Age 
rename age Age

*Education
recode edu (1=1 "Primary") (4=2 "Vocational") (2 3=3 "High school") (5=4 "Short Higher") (6=5 "Medium Higher") (7=6 "Higher") (8=7 "Doctorate") (9=.), generate(edutype)
generate Education = (edutype-1)/6 

*Support for social welfare
generate welfare=(welf-1)/10
label variable welfare "Support social welfare"

*Taxing the rich
recode tax_rich (1=11) (2=10) (3=9) (4=8) (5=7) (6=6) (7=5) (8=4) (9=3) (10=2) (11=1)
generate taxrich=(tax_rich-1)/10 
label variable taxrich "Oppose taxing rich"

*Party 
recode part (1 2 5 10 11=0 "Left parties") (12 13 14 15=1 "Other") (3 4 6 7 8 9=2 "Right parties"), generate(party)

*Income
recode inc (1=1) (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10) (11=11) (12=.) (13=.)
generate Income=(inc-1)/10

*Alternative measure: Upperclass taxes 
generate upper=(overtax-1)/4

save "prepared data 1", replace

********************
******Sample 2******
********************

use "Data2", clear 

*Effort of the poor  
generate poor_hard =(q7a_1-1)/6
generate poor_lazy =(q7a_2-1)/6
generate neffort_poor = (poor_hard - poor_lazy)
generate effort_poor= (neffort_poor+1)/2
label variable effort_poor "Effort poor"

*Prosociality of the poor 
generate poor_gen =(q7a_3-1)/6
generate poor_greed =(q7a_4-1)/6
generate nproso_poor = (poor_gen - poor_greed)
generate proso_poor = (nproso_poor+1)/2
label variable proso_poor "Prosocial poor"

*Compassion poor
generate comp_p =(q7b_1-1)/6
label variable comp_p "Compassion poor"

*Envy poor
generate envy_p =(q7b_2-1)/6
label variable envy_p "Envy poor"

*Admiration poor
generate admi_p =(q7b_3-1)/6
label variable admi_p "Admiration poor"

*Effort of the rich 
generate rich_hard =(q8a_1-1)/6
generate rich_lazy =(q8a_2-1)/6
generate neffort_rich = (rich_hard - rich_lazy)
generate effort_rich = (neffort_rich+1)/2
label variable effort_rich "Effort rich"

*Prosociality of the rich 
generate rich_gen =(q8a_3-1)/6
generate rich_greed =(q8a_4-1)/6
generate nproso_rich = (rich_gen - rich_greed)
generate proso_rich = (nproso_rich+1)/2
label variable proso_rich "Prosocial rich"

*Compassion rich
generate comp_r =(q8b_1-1)/6
label variable comp_r "Compassion rich"

*Envy rich
generate envy_r =(q8b_2-1)/6
label variable envy_r "Envy rich"

*Admiration rich
generate admi_r =(q8b_3-1)/6
label variable admi_r "Admiration rich"

*Support for social welfare support 
recode q10_1 (1=1) (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (977=.)
generate welfare =(q10_1-1)/6
label variable welfare "Support social welfare"

*Opposition for taxing the rich 
recode q11_1 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (977=.)
generate taxrich =(q11_1-1)/6
label variable taxrich "Oppose taxing rich"

*Income 
recode income (1=1) (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10) (11=11) (12=12) (976=.) (977=.)
gen Income = (income-1)/11

*Party
recode q26 (1=0 "Left") (3 4 5 977=1 "Independent") (2=2 "Right") , generate(party)  

*Race/Ethnicity 
recode q29 (1=1 "Majority") (2 3 4 5 6 =0 "Minority"), gen(Race)

*Gender
recode gender (1=1 "Male") (2=0 "Female"), gen(Gender)
label variable Gender "Gender (Male)"

*Age 
rename age Age

*Education 
gen Education =(edu-1)/3

*Alternative measure: Taxes on large corporations
recode q11_2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (977=.)
generate taxcor =(q11_2-1)/6

*Alternative measure: Upperclass taxes 
recode q12_3 (1=5) (2=4) (3=3) (4=2) (5=1) (977=.), generate(uppertax) 
generate upper=(uppertax-1)/4

*Alternative measures of effort of the poor and effort of the rich 
generate ef_poor =(q2_1-1)/6
label variable ef_poor "Effort alternative poor"

generate ef_rich =(q2_3-1)/6
label variable ef_rich "Effort alternative rich"

*Alternative measures of prosociality of the poor and prosociality of the rich

generate warm_poor =(q3_1-1)/6
generate like_poor =(q4_1-1)/6
alpha like_poor warm_poor, generate(pro_poor) 
label variable pro_poor "Prosocial alternative poor"

generate warm_rich =(q3_3-1)/6
generate like_rich =(q4_3-1)/6
alpha like_rich warm_rich, generate(pro_rich) 
label variable pro_rich "Prosocial alternative rich"

***Variables used in Supplementary Material Table A10
*Reversed Lazy poor 
recode q7a_2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen(plazyv)
generate vpoor_lazy =(plazyv-1)/6

*Reversed Greedy poor 
recode q7a_4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen(pgrev)
generate vpoor_greed =(pgrev-1)/6

*Reversed lazy rich 
recode q8a_2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen(rlazyv)
generate vrich_lazy =(rlazyv-1)/6

*Reversed greedy rich 
recode q8a_4 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1), gen(rgrev)
generate vrich_greed =(rgrev-1)/6

save "prepared data 2", replace

********************
******Sample 3******
********************
use "Data3", clear 

*Gender 
recode gender (2=0 "Female") (1=1 "Male"), generate(Gender) 
label variable Gender "Gender (Male)"

*Age 
replace year=. if year==18702
gen Age =(2020-year)

*Experimental treatment
generate stimuli =.
replace stimuli = 1 if experimentalconditions_do=="t1"
replace stimuli = 1 if experimentalconditions_do=="t1r"
replace stimuli = 2 if experimentalconditions_do=="t2"
replace stimuli = 2 if experimentalconditions_do=="t2r"
replace stimuli = 3 if experimentalconditions_do=="t3"
replace stimuli = 3 if experimentalconditions_do=="t3r"
replace stimuli = 4 if experimentalconditions_do=="t4"
replace stimuli = 4 if experimentalconditions_do=="t4r"
replace stimuli = 5 if experimentalconditions_do=="t5"
replace stimuli = 5 if experimentalconditions_do=="t5r"
replace stimuli = 6 if experimentalconditions_do=="t6"
replace stimuli = 6 if experimentalconditions_do=="t6r"
replace stimuli = 7 if experimentalconditions_do=="t7"
replace stimuli = 7 if experimentalconditions_do=="t7r"
replace stimuli = 8 if experimentalconditions_do=="t8"
replace stimuli = 8 if experimentalconditions_do=="t8r"

recode stimuli (1=1 "p_ef_gen") (2=2 "p_la_gen") (3=3 "p_ef_gre") (4=4 "p_la_gre") (5=5 "r_ef_gen") (6=6 "r_la_gen") (7=7 "r_ef_gre") (8=8 "r_la_gre"), gen(conditions) ///

generate effort=. 
replace effort = 1 if stimuli==1
replace effort = 0 if stimuli==2
replace effort = 1 if stimuli==3
replace effort = 0 if stimuli==4
replace effort = 1 if stimuli==5
replace effort = 0 if stimuli==6
replace effort = 1 if stimuli==7
replace effort = 0 if stimuli==8
label define effortvalues 0 "No effort" 1 "Effort"
label values effort effortvalues

generate proso=.
replace proso = 1 if stimuli==1
replace proso = 1 if stimuli==2
replace proso = 0 if stimuli==3
replace proso = 0 if stimuli==4
replace proso = 1 if stimuli==5
replace proso = 1 if stimuli==6
replace proso = 0 if stimuli==7
replace proso = 0 if stimuli==8
label define prosovalues 0 "Greedy" 1 "Generous"
label values proso prosovalues

generate rich=.
replace rich = 0 if stimuli==1
replace rich = 0 if stimuli==2
replace rich = 0 if stimuli==3
replace rich = 0 if stimuli==4
replace rich = 1 if stimuli==5
replace rich = 1 if stimuli==6
replace rich = 1 if stimuli==7
replace rich = 1 if stimuli==8
label define richvalues 0 "Poor" 1 "Rich"
label values rich richvalues

*Support for social welfare 
gen poor1 =(deppoor_1-1)/6 
rename poor1 welfare
label variable welfare "Support social welfare"

*Poor inequality 
gen poor2 =(deppoor_2-1)/6 
rename poor2 poorinequality
label variable poorinequality "Poor inequality"

*Help poor 
gen poor3 =(deppoor_3-1)/6 
rename poor3 help
label variable help "Help poor"

*Demand from the rich
recode deprich_1 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
gen rich2 =(deprich_1-1)/6 
rename rich2 demand
label variable demand "Demand from rich"

*Oppose taxing the rich 
recode deprich_2 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
gen rich1 =(deprich_2-1)/6 
rename rich1 taxrich
label variable taxrich "Oppose taxing rich"

*Rich inequality 
recode deprich_3 (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1)
gen rich3 =(deprich_3-1)/6 
rename rich3 richinequality
label variable richinequality "Rich inequality"

*Admiration 
gen admi =(emo_1-1)/6 
label variable admi "Admiration"

*Compassion 
gen comp =(emo_2-1)/6 
label variable comp "Compassion"

*Envy 
gen envy =(emo_3-1)/6 
label variable envy "Envy"

*Education 
gen Education= (education-1/7)

*Party
recode part (1=0 "Left") (3 4 5 6=1 "Independent") (2=2 "Right"), generate(party)

*Income 
recode income (1=1) (2=2) (3=3) (4=4) (5=5) (6=6) (7=7) (8=8) (9=9) (10=10) (11=11) (12=12) (13=.) (14=.)
gen Income =(income-1)/11

save "prepared data 3", replace

********************
******Sample 4******
********************

use "Data4", clear

*Prosociality of the poor 
recode Q23a (9=.)
gen proso_poor = (Q23a-1)/6
label variable proso_poor "Prosocial poor"

*Prosociality of the rich
recode Q23b (9=.)
gen proso_rich = (Q23b-1)/6
label variable proso_rich "Prosocial rich"

*Effort of the poor  
recode Q24a (9=.)
gen effort_poor = (Q24a-1)/6
label variable effort_poor "Effort poor"

*Effort of the rich 
recode Q24b (9=.)
gen effort_rich = (Q24b-1)/6
label variable effort_rich "Effort rich"

*Compassion poor 
recode Q25b (9=.)
gen comp_p = (Q25b-1)/6
label variable comp_p "Compassion poor"

*Envy poor  
recode Q25c (9=.)
gen envy_p = (Q25c-1)/6
label variable envy_p "Envy poor"

*Admiration poor  
recode Q25d (9=.)
gen admi_p = (Q25d-1)/6
label variable admi_p "Admiration poor"

*Compassion rich  
recode Q26b (9=.)
gen comp_r = (Q26b-1)/6
label variable comp_r "Compassion rich"

*Envy rich  
recode Q26c (9=.)
gen envy_r = (Q26c-1)/6
label variable envy_r "Envy rich"

*Admiration rich  
recode Q26d (9=.)
gen admi_r = (Q26d-1)/6
label variable admi_r "Admiration rich"

*Support for social welfare
recode Q27a (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (9=.)
gen welfare = (Q27a-1)/6
label variable welfare "Support social welfare"

*Opposition to taxing the rich
recode Q27b (1=7) (2=6) (3=5) (4=4) (5=3) (6=2) (7=1) (9=.)
gen taxrich = (Q27b-1)/6
label variable taxrich "Oppose taxing rich"

*Gender 
recode BVQ_01 (1=1 "Male") (2=0 "Female"), generate(Gender)
label variable Gender "Gender (Male)"

*Age
generate Age =(2020-BVQ_02_3)

*Education 
recode HF_Udd_grp (1=1 "Grundskole og uoplyst") (2=2 "Gymnasial og erhvervsfaglig uddannelse") (3=3 "KVU") (4=4 "MVUogBachelor") (5=5 "LVUogPh.D"), gen(Educationtype)                           
generate Education = (HF_Udd_grp-1)/4

*Party 
recode BVQ_26 (1 2 6 12 13=0 "Left") (14 88=1 "Independent") (3 4 5 7 8 9 10 11=2 "Right") , generate(party)

*Income 
rename BVQ_32 Income

*Race/Ethnicity 
recode BVQ_35 (1=1 "Majority") (2 8=0 "Minority"), generate(Race) 

*Alternative measure of opposition to taxing the rich 
recode Q8a (9=.)
gen richshare = (Q8a-1)/4

save "prepared data 4", replace